ValueFolderTemp='C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\ResultsJournal\';
ValueFolderTemp2='C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\ResultsEditor\';
load([ValueFolderTemp 'ResultsThirdLevelDistributionOutliers.mat']);
VecDistribution=VecResults;
load('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\EtudeNature.mat');
VecEditors1Temp(1,:)=[];
VecValueEditor=VecEditors1Temp;
load('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\DonneesNature.mat');
VecValueJournal=VecJournalTemp;
load('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\Results\NCoAuthorsEditors.mat');
VecResultsCoAuthorsTemp=VecResultsCoAuthors;
VecValueJournalStart=xlsread('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\pubmed\DonneesNature.xlsx',1);
ValueCutoff=1.25;
VecFigure=[];
VecFigure2=[];
VecFigure3=[];
VecFigure5=[];
VecFigure6=[];
VecResultsCoAuthors=[];
VecResultsCoAuthors2=[];
VecResultsCoAuthors3=[];
VecResultsEditorsCoAuthorsTemp=zeros(1,4);
VecResultsEditorAfter=[];
VecResultsEditorBefore=[];
VecResultsEditorTemp2=[];
VecResultsEditorCoAuthors=[];
VecResultsEditorCoAuthors2=[];
VecResultsEditorJournal=[];
VecResultsEditorJournal2=[];
VecResultsTemp5Temp=[];
VecResultsTemp6Temp=[];
VecResultsEditorsJournalBefore=[14 4;43 33;64 12;103 28;132 21;149 28;199 4;282 33;241 2];
for n1=1:323
    n1
    ValueTemp=find(VecDistribution(:,1)==n1);
    ValueStartEditor=VecValueEditor{n1,22};
    n5Temp5=0;
    if size(ValueTemp,1)==1&&n1~=11
        if VecDistribution(ValueTemp,2)<=ValueCutoff
            ValueJournal=VecValueEditor{n1,11};
            ValueTempBefore=find(VecResultsEditorsJournalBefore(:,1)==n1);
            if size(ValueTempBefore,1)==1
                n3=VecResultsEditorsJournalBefore(ValueTempBefore,2);
            else
                n3=1;
                TestTemp=0;
                while n3<=size(VecValueJournal,1)&&TestTemp==0
                    if strcmpi(ValueJournal,VecValueJournal{n3,1})==1
                        TestTemp=1;
                    else
                        n3=n3+1;
                    end
                end
            end
%             ValueFileTemp4=dir([ValueFolderTemp2 'FileAnalysisEditorCoAuthors' num2str(n1) 'RestrictedYear2Month8.mat']);
%             if size(ValueFileTemp4,1)==1
                load([ValueFolderTemp2 'FileAnalysisEditorCoAuthors' num2str(n1) 'RestrictedYear2Month8.mat']);
                if size(VecGroupCoAuthors,1)>=1
                    nCoAuthors=0;
                    nCoAuthors1=VecGroupCoAuthors{1,1};
                    nCoAuthors2=size(VecGroupCoAuthors,1);
                    for n7=1:size(VecGroupCoAuthors,1)
                        nCoAuthors=nCoAuthors+VecGroupCoAuthors{n7,1};
                    end
                else
                    nCoAuthors=NaN;
                    nCoAuthors1=NaN;
                    nCoAuthors2=NaN;
                end
                load([ValueFolderTemp2 'FileAnalysisCharacteristicsEditor' num2str(n1) '.mat']);
                VecValueTemp24=[];
                VecValueTemp25=[];
                VecValueTemp26=[];
                VecValueTemp24Temp=[];
                VecValueTemp25Temp=[];
                ValueTime=clock();
                n5Temp=0;
                for n2=1:33
                    if n2==n3
                        eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2;']);
%                         eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
                        VecValueTemp22=VecValueTemp';
                        eval(['VecValueTemp=VecResultsOtherAuthors' num2str(n2) 'j1y1m2;']);
%                         eval(['VecValueTemp=VecResultsOtherAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
                        VecValueTemp23=VecValueTemp';
                        eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']); % robustness analysis for the first group of co-authors
                        VecResultsTemp5Temp=[VecResultsTemp5Temp;size(VecValueTemp22,1) size(VecValueTemp2,2) VecResultsCoAuthorsTemp(n1,1:3)];
                    else
                        eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2;']);
                        eval(['VecValueTemp3=VecResultsOtherAuthors' num2str(n2) 'j1y1m2;']);
%                         eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
%                         eval(['VecValueTemp3=VecResultsOtherAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
                        if size(VecValueTemp24,2)==0&&size(VecValueTemp,2)>=1
                            VecValueTemp24=VecValueTemp;
                            VecValueTemp25=VecValueTemp;
                            VecValueTemp26=VecValueTemp3;
                            eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1m;']);
%                             eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']); % robustness analysis for the first group of co-authors
                            VecValueTemp24Temp=VecValueTemp2;
                            n5Temp=n5Temp+1;
                        else
                            if size(VecValueTemp,2)>=1
                                eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1m;']);
%                                 eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']); % robustness analysis for the first group of co-authors
                                for n4=1:size(VecValueTemp2,2)
                                    n5=1;
                                    TestTemp=0;
                                    while TestTemp==0&&n5<=size(VecValueTemp24Temp,2)
                                        if size(VecValueTemp24Temp{1,n5},2)==size(VecValueTemp2{1,n4},2)&&sum(abs(VecValueTemp24Temp{1,n5}-VecValueTemp2{1,n4}))==0
                                            TestTemp=1;
                                        else
                                            n5=n5+1;
                                        end
                                    end
                                    if n5<=size(VecValueTemp24Temp,2)
                                        VecValueTemp24(:,n5)=VecValueTemp24(:,n5)+VecValueTemp(:,n4);
                                    else
                                        VecValueTemp24(:,n5)=VecValueTemp(:,n4);
                                        VecValueTemp24Temp(1,n5)={VecValueTemp2{1,n4}};
                                    end
                                    n5Temp=n5Temp+1;
                                end
                                VecValueTemp25=[VecValueTemp25 VecValueTemp];
                                VecValueTemp26=[VecValueTemp26 VecValueTemp3];
                                if size(VecValueTemp2,2)>0
                                    n5Temp5=n5Temp5+1;
                                end
                            end
                        end
                    end
                end
                ValueTime2=clock();
                ValueTimeTemp=(ValueTime2(1,4)-ValueTime(1,4))*60+ValueTime2(1,5)-ValueTime(1,5);
                VecValueTemp24=VecValueTemp24';
                VecValueTemp24Temp=VecValueTemp24;
                if size(VecValueTemp22,1)>=1
                    ValueTemp5=find(isnan(VecValueTemp22(:,2))==0);
                    ValueTemp5=size(ValueTemp5,1);
                else
                    ValueTemp5=0;
                end
                if size(VecValueTemp24,1)>=1
                    ValueTemp4=find(isnan(VecValueTemp24(:,2))==0);
                    VecResultsCoAuthors=[VecResultsCoAuthors;size(ValueTemp4,1) ValueTemp5 VecResultsEditor(1,16) size(ValueTemp4,1)/VecResultsEditor(1,16) ValueTemp5/VecResultsEditor(1,16) VecResultsCoAuthorsTemp(n1,1:3) nCoAuthors1 nCoAuthors nCoAuthors2 n1];
                else
                    VecResultsCoAuthors=[VecResultsCoAuthors;0 ValueTemp5 VecResultsEditor(1,16) 0 ValueTemp5/VecResultsEditor(1,16) VecResultsCoAuthorsTemp(n1,1:3) nCoAuthors1 nCoAuthors nCoAuthors2 n1];
                end
                VecValueTemp24=VecValueTemp25';
                VecValueTemp26=VecValueTemp26';
                if size(VecValueTemp22,1)>=1&&size(VecValueTemp23,1)>=1
                    if size(VecValueEditor{n1,22},2)<=3||size(ValueTempBefore,1)==1
    %                 if size(VecValueTemp22,2)>=1&&size(VecValueTemp23,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,1)<=15&&VecResultsCoAuthors(end,1)>=1
    %                 if size(VecValueTemp22,2)>=1&&size(VecValueTemp23,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,5)<=13
                        % First column of VecValueTemp22 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
                        VecFigure3=[VecFigure3;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
                        VecFigure3=[VecFigure3;VecValueTemp23 VecValueTemp23(:,1)+VecValueTemp23(:,2) VecValueTemp23(:,1)-VecValueTemp23(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp23,1),1) n3*ones(size(VecValueTemp23,1),1) 2*ones(size(VecValueTemp23,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp23,1),1) n1*ones(size(VecValueTemp23,1),1)];
                        ValueTemp=find(VecValueTemp22(:,1)==0&VecValueTemp22(:,2)>0);
                        ValueTemp2=find(VecValueTemp23(:,1)==0&VecValueTemp23(:,2)>0);
                        VecFigure5=[VecFigure5;size(ValueTemp,1) size(VecValueTemp22,1) size(ValueTemp2,1) size(VecValueTemp23,1)];
                        if n1~=125&&n1~=151&&n1~=303
                            VecResultsEditorCoAuthors=[VecResultsEditorCoAuthors;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1 size(VecValueTemp22,1) size(VecValueTemp23,1)];
                        else
                            VecResultsEditorCoAuthors2=[VecResultsEditorCoAuthors2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1];
                        end
                        if n1~=125&&n1~=151&&n1~=303
                            if sum(VecValueTemp22(:,2))==0
                                if sum(VecValueTemp22(:,1))>0
                                    VecResultsEditorsCoAuthorsTemp(1,1)=VecResultsEditorsCoAuthorsTemp(1,1)+1;
                                else
                                    VecResultsEditorsCoAuthorsTemp(1,2)=VecResultsEditorsCoAuthorsTemp(1,2)+1;
                                end
                            else
                                if sum(VecValueTemp22(:,1))>0
                                    VecResultsEditorsCoAuthorsTemp(1,3)=VecResultsEditorsCoAuthorsTemp(1,3)+1;
                                else
                                    VecResultsEditorsCoAuthorsTemp(1,4)=VecResultsEditorsCoAuthorsTemp(1,4)+1;
                                end
                            end
                        end
                        if size(VecValueTemp24Temp,1)>=1
                            ValueTemp4=find(isnan(VecValueTemp24Temp(:,2))==0);
                            VecResultsCoAuthors3=[VecResultsCoAuthors3;size(ValueTemp4,1) ValueTemp5 VecResultsEditor(1,16) size(ValueTemp4,1)/VecResultsEditor(1,16) ValueTemp5/VecResultsEditor(1,16)];
                        else
                            VecResultsCoAuthors3=[VecResultsCoAuthors3;0 ValueTemp5 VecResultsEditor(1,16) 0 ValueTemp5/VecResultsEditor(1,16)];
                        end
                        if size(VecValueTemp25,1)>=1
                            VecValueTemp25=VecValueTemp25';
                            VecFigure6=[VecFigure6;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1)];
                            VecFigure6=[VecFigure6;VecValueTemp23 VecValueTemp23(:,1)+VecValueTemp23(:,2) VecValueTemp23(:,1)-VecValueTemp23(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp23,1),1) n3*ones(size(VecValueTemp23,1),1) 2*ones(size(VecValueTemp23,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp23,1),1) n1*ones(size(VecValueTemp23,1),1) ones(size(VecValueTemp23,1),1)];
                            VecFigure6=[VecFigure6;VecValueTemp25 VecValueTemp25(:,1)+VecValueTemp25(:,2) VecValueTemp25(:,1)-VecValueTemp25(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp25,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp25,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp25,1),1) n3*ones(size(VecValueTemp25,1),1) ones(size(VecValueTemp25,1),1) size(VecValueTemp25,1)*ones(size(VecValueTemp25,1),1) n1*ones(size(VecValueTemp25,1),1) 2*ones(size(VecValueTemp25,1),1)];
                            VecFigure6=[VecFigure6;VecValueTemp26 VecValueTemp26(:,1)+VecValueTemp26(:,2) VecValueTemp26(:,1)-VecValueTemp26(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp26,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp26,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp26,1),1) n3*ones(size(VecValueTemp26,1),1) 2*ones(size(VecValueTemp26,1),1) size(VecValueTemp25,1)*ones(size(VecValueTemp26,1),1) n1*ones(size(VecValueTemp26,1),1) 2*ones(size(VecValueTemp26,1),1)];
                        end
                    else
                        if size(VecValueTemp22,1)>=1&&size(VecValueTemp23,1)>=1
                            VecResultsTemp6Temp=[VecResultsTemp6Temp;n1];
                        end
                        VecResultsEditorCoAuthors2=[VecResultsEditorCoAuthors2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1];
                    end
                else
                    if size(VecValueTemp22,1)>=1&&size(VecValueTemp23,1)>=1
                        VecResultsTemp6Temp=[VecResultsTemp6Temp;n1];
                    end
                    VecResultsEditorCoAuthors2=[VecResultsEditorCoAuthors2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1];
                end
                if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1
                    if size(VecValueEditor{n1,22},2)<=3||size(ValueTempBefore,1)==1
    %                 if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,1)<=15&&VecResultsCoAuthors(end,1)>=1
    %                 if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,4)<=50
                        % First column of VecValueTemp24 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
                        VecFigure2=[VecFigure2;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
    %                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp (VecValueTemp24(:,1)+VecValueTemp24(:,2)) (VecValueTemp24(:,1)-VecValueTemp24(:,2)) VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
                        VecFigure2=[VecFigure2;VecValueTemp24 VecValueTemp24(:,1)+VecValueTemp24(:,2) VecValueTemp24(:,1)-VecValueTemp24(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
                        VecResultsEditorJournal=[VecResultsEditorJournal;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27)];
                        if size(VecValueTemp24Temp,1)>=1
                            ValueTemp4=find(isnan(VecValueTemp24Temp(:,2))==0);
                            VecResultsCoAuthors2=[VecResultsCoAuthors2;size(ValueTemp4,1) ValueTemp5 VecResultsEditor(1,16) size(ValueTemp4,1)/VecResultsEditor(1,16) ValueTemp5/VecResultsEditor(1,16)];
                        else
                            VecResultsCoAuthors2=[VecResultsCoAuthors2;0 ValueTemp5 VecResultsEditor(1,16) 0 ValueTemp5/VecResultsEditor(1,16)];
                        end
                    else
                        if size(VecValueEditor{n1,22},2)<=3
                            VecResultsEditorJournal2=[VecResultsEditorJournal2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27)];
                        end
                    end
                else
                    if size(VecValueEditor{n1,22},2)<=3
                        VecResultsEditorJournal2=[VecResultsEditorJournal2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27)];
                    end
                end
%                 % Robustness analysis (we average over the number of Nature journals)
%                 if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&n5Temp5>0
%                     % First column of VecValueTemp24 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
%                     VecFigure2=[VecFigure2;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
% %                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp (VecValueTemp24(:,1)+VecValueTemp24(:,2))/n5Temp (VecValueTemp24(:,1)-VecValueTemp24(:,2))/n5Temp VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
%                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp5 VecValueTemp24(:,1)+VecValueTemp24(:,2) (VecValueTemp24(:,1)-VecValueTemp24(:,2))/n5Temp5 VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
%                 end
%             end
        end
    end
end

% [ValueResults,ValueResults2,stats]=fishertest([VecResultsEditorsCoAuthorsTemp(1,1) VecResultsEditorsCoAuthorsTemp(1,4);sum(VecResultsEditorsCoAuthorsTemp(1,1:4))-VecResultsEditorsCoAuthorsTemp(1,1) sum(VecResultsEditorsCoAuthorsTemp(1,1:4))-VecResultsEditorsCoAuthorsTemp(1,4)]);
% 
% VecResultsEditorTemp=[];
% VecResultsEditorAfter=VecResultsEditorCoAuthors;
% VecResultsEditorBefore=VecResultsEditorCoAuthors2;
% ValueTemp=find(VecResultsEditorAfter(:,1)==44);
% VecResultsEditorAfter(ValueTemp,:)=[];
% ValueTemp=find(VecResultsEditorBefore(:,1)==44);
% VecResultsEditorBefore(ValueTemp,:)=[];
% for n1=1:3
%     ValueTemp=find(isnan(VecResultsEditorAfter(:,n1))==0);
%     ValueTemp2=find(isnan(VecResultsEditorBefore(:,n1))==0);
%     [ValueResults,ValueResults2]=ttest2(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     [ValueResults3,ValueResults4]=ranksum(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     VecResultsEditorTemp=[VecResultsEditorTemp;mean(VecResultsEditorAfter(ValueTemp,n1)) sqrt(var(VecResultsEditorAfter(ValueTemp,n1))) median(VecResultsEditorAfter(ValueTemp,n1)) quantile(VecResultsEditorAfter(ValueTemp,n1),0.25) quantile(VecResultsEditorAfter(ValueTemp,n1),0.75) mean(VecResultsEditorBefore(ValueTemp2,n1)) sqrt(var(VecResultsEditorBefore(ValueTemp2,n1))) median(VecResultsEditorBefore(ValueTemp2,n1)) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.25) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.75) ValueResults2 ValueResults3 size(ValueTemp,1) size(ValueTemp2,1)];
% end
% VecResultsEditorAfter=VecResultsEditorJournal;
% VecResultsEditorBefore=VecResultsEditorJournal2;
% for n1=1:3
%     ValueTemp=find(isnan(VecResultsEditorAfter(:,n1))==0);
%     ValueTemp2=find(isnan(VecResultsEditorBefore(:,n1))==0);
%     [ValueResults,ValueResults2]=ttest2(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     [ValueResults3,ValueResults4]=ranksum(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     VecResultsEditorTemp=[VecResultsEditorTemp;mean(VecResultsEditorAfter(ValueTemp,n1)) sqrt(var(VecResultsEditorAfter(ValueTemp,n1))) median(VecResultsEditorAfter(ValueTemp,n1)) quantile(VecResultsEditorAfter(ValueTemp,n1),0.25) quantile(VecResultsEditorAfter(ValueTemp,n1),0.75) mean(VecResultsEditorBefore(ValueTemp2,n1)) sqrt(var(VecResultsEditorBefore(ValueTemp2,n1))) median(VecResultsEditorBefore(ValueTemp2,n1)) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.25) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.75) ValueResults2 ValueResults3 size(ValueTemp,1) size(ValueTemp2,1)];
% end

% ValueTemp=find(isnan(VecResultsCoAuthors(:,10))==0);
% VecResultsCoAuthorsTemp6=VecResultsCoAuthors(ValueTemp,:);
% ValueTemp=find(VecResultsCoAuthorsTemp6(:,10)-mean(VecResultsCoAuthorsTemp6(:,10))<=2*sqrt(var(VecResultsCoAuthorsTemp6(:,10))));
% ValueTemp=find(isnan(VecResultsCoAuthors(:,9))==0);
% VecResultsCoAuthorsTemp6=VecResultsCoAuthors(ValueTemp,:);
% ValueTemp=find(VecResultsCoAuthorsTemp6(:,9)-mean(VecResultsCoAuthorsTemp6(:,9))<=2*sqrt(var(VecResultsCoAuthorsTemp6(:,9))));

VecFigure4=VecFigure;
% VecFigure=VecFigure2;
% VecFigure=VecFigureTemp;
VecFigureTemp=VecFigure;
VecFigure=VecFigure3;
% VecFigure=VecFigure6;
ValueTemp=find(VecFigure(:,3)==0);
% ValueTemp=find(VecFigure(:,3)>8);
VecFigure(ValueTemp,:)=[];
ValueTemp=find(VecFigure(:,11)==125); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
VecFigure(ValueTemp,:)=[];
ValueTemp=find(VecFigure(:,11)==151); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
VecFigure(ValueTemp,:)=[];
ValueTemp=find(VecFigure(:,11)==303); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
VecFigure(ValueTemp,:)=[];
% ValueResultTemp=[];
% ValueTemp=find(abs(VecFigure(:,3)-mean(VecFigure(:,3)))<=5*sqrt(var(VecFigure(:,3))));
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% ValueTemp=find(abs(VecFigure(:,3)-mean(VecFigure(:,3)))<=3*sqrt(var(VecFigure(:,3)))); % Robustness analysis for the threshold used to remove homonyms among authors
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% ValueTemp=find(abs(VecFigure(:,3)-mean(VecFigure(:,3)))<=4*sqrt(var(VecFigure(:,3)))); % Robustness analysis for the threshold used to remove homonyms among authors
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% ValueTemp=find(abs(VecFigure(:,3)-mean(VecFigure(:,3)))<=6*sqrt(var(VecFigure(:,3)))); % Robustness analysis for the threshold used to remove homonyms among authors
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% ValueTemp=find(abs(VecFigure(:,3)-mean(VecFigure(:,3)))<=7*sqrt(var(VecFigure(:,3)))); % Robustness analysis for the threshold used to remove homonyms among authors
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% VecFigure=VecFigure(ValueTemp,:);
[ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,5,3);
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% [ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,3,3); % Robustness analysis for the threshold used to remove homonyms
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% [ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,4,3); % Robustness analysis for the threshold used to remove homonyms
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% [ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,6,3); % Robustness analysis for the threshold used to remove homonyms
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
% [ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,7,3); % Robustness analysis for the threshold used to remove homonyms
% ValueResultTemp=[ValueResultTemp; size(ValueTemp,1) size(VecFigure,1)];
VecFigure=ValueTemp;


for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
% VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
% ValueResults=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
% ValueResults
TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==1
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel1=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
% VecValueTemp5=repmat('C',size(VecFigure,1),1); % Editor's journal
% ValueTemp=find(VecFigure(:,12)==2);
% VecValueTemp5(ValueTemp,1)=repmat('D',size(ValueTemp,1),1); % Other journals
ValueTemp=find(VecValueTemp=='E');
% ValueTemp=find(VecValueTemp(:,1)=='E'&VecValueTemp5(:,1)=='D');
VecFigure=[VecFigure(ValueTemp(1,1):end,:);VecFigure(1:ValueTemp(1,1)-1,:)];
VecValueTemp=[VecValueTemp(ValueTemp(1,1):end,:);VecValueTemp(1:ValueTemp(1,1)-1,:)];
% VecValueTemp5=[VecValueTemp5(ValueTemp(1,1):end,:);VecValueTemp5(1:ValueTemp(1,1)-1,:)];
% VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
% ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
% VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecFigure(:,5);VecFigure(:,5)],[VecFigure(:,6);VecFigure(:,6)],[VecFigure(:,7);VecFigure(:,7)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
% ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle*Variable27+(1|Editor)','FitMethod','REML');
% VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecFigure(:,5);VecFigure(:,5)],[VecFigure(:,6);VecFigure(:,6)],[VecFigure(:,7);VecFigure(:,7)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
% ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor+ArticlesBefore+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3
% VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
% ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3
VecValueTemp4=table(VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
ValueResultsModel1Temp4=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3 pour comparer entre les co-auteurs et les autres auteurs le nombre d'articles publi�s avant l'arriv�e de l'�diteur
% VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
% ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure2
% VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),VecValueTemp5,'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor','Journal'});
% ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Journal+ArticlesBefore+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure6
% VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,repmat('A',size(VecFigure,1),1),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
% ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML');
% VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,repmat('A',size(VecFigure,1),1),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
% ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML');
% ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML');
VecFigureTemp=VecFigure;
ValueTemp=find(VecFigureTemp(:,1)>=1);
VecFigureTemp(ValueTemp,1)=ones(size(ValueTemp,1),1);
ValueTemp=find(VecFigureTemp(:,2)>=1);
VecFigureTemp=VecFigureTemp(ValueTemp,:);
VecValueTemp=VecValueTemp(ValueTemp,:);
% VecValueTemp5=[VecValueTemp5(4:end,:);VecValueTemp5(1:3,:)]; % If commented, results are for authors who arrived before
% VecValueTemp=[VecValueTemp(4:end,:);VecValueTemp(1:3,:)]; % If commented, results are for authors who arrived before
% VecFigureTemp=[VecFigureTemp(4:end,:);VecFigureTemp(1:3,:)]; % If commented, results are for authors who arrived before
VecValueTemp4=table(VecFigureTemp(:,1),VecValueTemp,VecFigureTemp(:,2),VecFigureTemp(:,11),'VariableNames',{'ArticlesAfter','CategoryAuthor','ArticlesBefore','Editor'});
ValueResultsModel1Temp3=fitglme(VecValueTemp4,'ArticlesAfter~CategoryAuthor+ArticlesBefore+(1|Editor)','Distribution','Binomial','Link','logit','BinomialSize',1,'Weights',ones(size(VecFigureTemp,1),1),'FitMethod','laplace');
% ValueResultsModel1Temp3=fitglme(VecValueTemp4,'ArticlesAfter~CategoryAuthor*ArticlesBefore+(1|Editor)','Distribution','Binomial','Link','logit','BinomialSize',1,'Weights',ones(size(VecFigureTemp,1),1),'FitMethod','laplace');

return

TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==2
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('E',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==2);
VecValueTemp(ValueTemp,1)=repmat('O',size(ValueTemp,1),1);
% Model for the analysis comparing the number of articles of former co-authors and the ther authors in the editor's journal
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel2=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel2Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel2Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel3=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable1+CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML');

return

% % Saving data for sharing
% VecValueTemp=repmat('E',size(VecFigure,1),1);
% ValueTemp=find(VecFigure(:,9)==2);
% VecValueTemp(ValueTemp,1)=repmat('O',size(ValueTemp,1),1);
% VecFigure=[VecFigure(:,4) VecFigure(:,11)];
% save('C:\Users\Remy Neveu\Desktop\Tests_R\AnalyseEtudeIRM\Nature\Statistical analyses\2nd set of results\AnalyseMixedModelCoAuthorsEditorJournal.mat','VecFigure','VecValueTemp');

VecFigure=VecFigure2;
ValueTemp=find(VecFigure(:,3)==0);
% ValueTemp=find(VecFigure(:,3)>8);
VecFigure(ValueTemp,:)=[];
% ValueTemp=find(abs(VecFigure(:,3)-mean(VecFigure(:,3)))<3*sqrt(var(VecFigure(:,3))));
% VecFigure=VecFigure(ValueTemp,:);
[ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,5,3);
VecFigure=ValueTemp;
for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
% VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
% ValueResults=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
% ValueResults
TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==1
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel4=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel4Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel4Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==2
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('E',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==2);
VecValueTemp(ValueTemp,1)=repmat('O',size(ValueTemp,1),1);
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel5=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel5Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel5Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel6=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable1+CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML');

% % Saving data for sharing
% VecValueTemp=repmat('E',size(VecFigure,1),1);
% ValueTemp=find(VecFigure(:,9)==2);
% VecValueTemp(ValueTemp,1)=repmat('O',size(ValueTemp,1),1);
% VecFigure=[VecFigure(:,4) VecFigure(:,11)];
% save('C:\Users\Remy Neveu\Desktop\Tests_R\AnalyseEtudeIRM\Nature\Statistical analyses\2nd set of results\AnalyseMixedModelCoAuthorsOnlyAllJournals.mat','VecFigure','VecValueTemp');

return

[ValueResults2,ValueResults2Temp]=ttest(VecFigure5(:,1)./VecFigure5(:,2)-VecFigure5(:,3)./VecFigure5(:,4))
[ValueResults2,ValueResults2Temp]=signrank(VecFigure5(:,1)./VecFigure5(:,2)-VecFigure5(:,3)./VecFigure5(:,4))

VecFigure=[];
VecFigure2=[];
VecFigure3=[];
VecFigure5=[];
for n1=1:323
    n1
    ValueTemp=find(VecDistribution(:,1)==n1);
    ValueStartEditor=VecValueEditor{n1,22};
    n5Temp5=0;
    if size(ValueTemp,1)==1&&n1~=11
        if VecDistribution(ValueTemp,2)<=ValueCutoff
            ValueJournal=VecValueEditor{n1,11};
            n3=1;
            TestTemp=0;
            while n3<=size(VecValueJournal,1)&&TestTemp==0
                if strcmpi(ValueJournal,VecValueJournal{n3,1})==1
                    TestTemp=1;
                else
                    n3=n3+1;
                end
            end
            load([ValueFolderTemp2 'FileAnalysisEditorCoAuthors' num2str(n1) 'RestrictedYear2Month8.mat']);
            load([ValueFolderTemp2 'FileAnalysisCharacteristicsEditor' num2str(n1) '.mat']);
            VecValueTemp24=[];
            VecValueTemp25=[];
            VecValueTemp24Temp=[];
            VecValueTemp25Temp=[];
            ValueTime=clock();
            for n2=1:33
                if n2==n3
                    eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2Filtered;']);
                    VecValueTemp22=VecValueTemp';
                    eval(['VecValueTemp=VecResultsOtherAuthors' num2str(n2) 'j1y1m2Filtered;']);
                    VecValueTemp23=VecValueTemp';
                else
                    eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m1Filtered;']);
                    if size(VecValueTemp24,2)==0&&size(VecValueTemp,2)>=1
                        VecValueTemp24=VecValueTemp;
                        eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']);
                        VecValueTemp24Temp=VecValueTemp2;
                    else
                        if size(VecValueTemp,2)>=1
                            eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']);
                            for n4=1:size(VecValueTemp2,2)
                                n5=1;
                                TestTemp=0;
                                while TestTemp==0&&n5<=size(VecValueTemp24Temp,2)
                                    if size(VecValueTemp24Temp{1,n5},2)==size(VecValueTemp2{1,n4},2)&&sum(abs(VecValueTemp24Temp{1,n5}-VecValueTemp2{1,n4}))==0
                                        TestTemp=1;
                                    else
                                        n5=n5+1;
                                    end
                                end
                                if n5<=size(VecValueTemp24Temp,2)
                                    VecValueTemp24(:,n5)=VecValueTemp24(:,n5)+VecValueTemp(:,n4);
                                else
                                    VecValueTemp24(:,n5)=VecValueTemp(:,n4);
                                    VecValueTemp24Temp(1,n5)={VecValueTemp2{1,n4}};
                                end
                            end
                            if size(VecValueTemp2,2)>0
                                n5Temp5=n5Temp5+1;
                            end
                        end
                    end
                end
            end
            ValueTime2=clock();
            ValueTimeTemp=(ValueTime2(1,4)-ValueTime(1,4))*60+ValueTime2(1,5)-ValueTime(1,5);
            VecValueTemp24=VecValueTemp24';
            VecValueTemp25=VecValueTemp25';
            if size(VecValueTemp22,2)>=1&&size(VecValueTemp23,2)>=1&&size(VecValueEditor{n1,22},2)<=3
                % First column of VecValueTemp22 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
                VecFigure3=[VecFigure3;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
                VecFigure3=[VecFigure3;VecValueTemp23 VecValueTemp23(:,1)+VecValueTemp23(:,2) VecValueTemp23(:,1)-VecValueTemp23(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp23,1),1) n3*ones(size(VecValueTemp23,1),1) 2*ones(size(VecValueTemp23,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp23,1),1) n1*ones(size(VecValueTemp23,1),1)];
                ValueTemp=find(VecValueTemp22(:,1)==0&VecValueTemp22(:,2)>0);
                ValueTemp2=find(VecValueTemp23(:,1)==0&VecValueTemp23(:,2)>0);
                VecFigure5=[VecFigure5;size(ValueTemp,1) size(VecValueTemp22,1) size(ValueTemp2,1) size(VecValueTemp23,1)];
            end
            if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3
                % First column of VecValueTemp24 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
                VecFigure2=[VecFigure2;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
%                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp (VecValueTemp24(:,1)+VecValueTemp24(:,2))/n5Temp (VecValueTemp24(:,1)-VecValueTemp24(:,2))/n5Temp VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
                VecFigure2=[VecFigure2;VecValueTemp24 VecValueTemp24(:,1)+VecValueTemp24(:,2) VecValueTemp24(:,1)-VecValueTemp24(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
            end
%             % Robustness analysis (we average over the number of Nature journals)
%             if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&n5Temp5>0
%                 % First column of VecValueTemp24 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
%                 VecFigure2=[VecFigure2;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
% %                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp (VecValueTemp24(:,1)+VecValueTemp24(:,2))/n5Temp (VecValueTemp24(:,1)-VecValueTemp24(:,2))/n5Temp VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
%                 VecFigure2=[VecFigure2;VecValueTemp24/n5Temp5 VecValueTemp24(:,1)+VecValueTemp24(:,2) (VecValueTemp24(:,1)-VecValueTemp24(:,2))/n5Temp5 VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
%             end
        end
    end
end

VecFigure=VecFigure3;
ValueTemp=find(VecFigure(:,3)==0);
% ValueTemp=find(VecFigure(:,3)>8);
VecFigure(ValueTemp,:)=[];
[ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,5,3);
VecFigure=ValueTemp;
for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
% VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
% ValueResults=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
% ValueResults
TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==1
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel1=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp&VecFigure(:,9)==2);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==2
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('E',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==2);
VecValueTemp(ValueTemp,1)=repmat('O',size(ValueTemp,1),1);
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel2=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel2Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel2Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel3=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable1+CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML');

VecFigure=VecFigure2;
ValueTemp=find(VecFigure(:,3)==0);
% ValueTemp=find(VecFigure(:,3)>8);
VecFigure(ValueTemp,:)=[];
[ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,5,3);
VecFigure=ValueTemp;
for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
% VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
% ValueResults=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
% ValueResults
TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==1
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('O',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==1);
VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel4=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel4Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel4Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
TestTemp=0;
ValueTemp=1;
while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
    ValueTemp2=find(VecFigure(:,11)==ValueTemp&VecFigure(:,9)==2);
    if size(ValueTemp2,1)>=1
        VecValueTemp2=VecFigure(ValueTemp2,:);
        if VecValueTemp2(1,9)==2
            TestTemp=1;
        end
    end
    ValueTemp=ValueTemp+1;
end
VecFigure(ValueTemp2,:)=[];
VecFigure=[VecValueTemp2;VecFigure];
VecValueTemp=repmat('E',size(VecFigure,1),1);
ValueTemp=find(VecFigure(:,9)==2);
VecValueTemp(ValueTemp,1)=repmat('O',size(ValueTemp,1),1);
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel5=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel5Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
ValueResultsModel5Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
for n1=1:3
    ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
    if size(ValueTemp,1)>0
        VecFigure(ValueTemp,:)=[];
        VecValueTemp(ValueTemp,:)=[];
    end
end
VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
ValueResultsModel6=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable1+CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML');

% save([ValueFolderTemp2 'ResultsFourthLevelEditorCoAuthorsFiltered.mat'],'ValueResultsModel1','ValueResultsModel1Temp','ValueResultsModel1Temp2','ValueResultsModel2','ValueResultsModel2Temp','ValueResultsModel2Temp2','ValueResultsModel3','ValueResultsModel4','ValueResultsModel4Temp','ValueResultsModel4Temp2','ValueResultsModel5','ValueResultsModel5Temp','ValueResultsModel5Temp2','ValueResultsModel6');

% save([ValueFolderTemp2 'AnalyseMixedModelFourthLevelCoAuthorsNonFiltered.mat'],'VecFigure');




